﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.OleDb;

/// <summary>
/// Summary description for Proekt
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class Proekt : System.Web.Services.WebService {
        public Proekt () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }
     [WebMethod]
    public List<Fabrika> vratiFabriki(int id)
    {
        OleDbConnection Myconnection = null;
        List<Fabrika> lf = new List<Fabrika>();
        Myconnection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\pc\Documents\Visual Studio 2008\WebSites\Proekt_indeks13604\App_Data\Fabriki1.mdb");
        Myconnection.Open();
        OleDbCommand cmd = Myconnection.CreateCommand();
        cmd.CommandText = "SELECT * From Fabriki Where idGrad=" + id;
        OleDbDataReader dr1 = cmd.ExecuteReader();
        while (dr1.Read())
        {
            Fabrika f = new Fabrika(dr1[0].ToString(), dr1[1].ToString(), dr1[2].ToString(), dr1[3].ToString(), dr1[4].ToString(), dr1[5].ToString());
            lf.Add(f);
        }
        return lf;
    }
  }
public class Fabrika
{
    public String ID;
    public String idGrad;
    public String imeFabrika;
    public String opis;
    public String adresa;
    public String cena;

public Fabrika()
    {

    }
public Fabrika(String id,String idg,String ime,String opi,String ad,String c)
	{
        ID = id;
        idGrad = idg;
        imeFabrika = ime;
        opis = opi;
        adresa = ad;
        cena = c;
	}
}

